First let me thank you for your wonderful Hf_crackme_s1. This is a very well written - at least IMHO - crackme which can really be a good challenge for every newbie; and for more experienced too.
Here's a short explanation how I find a way (well actually it's one way there are more of course) to get a real serial and how the calculation for this serial is working:
First start the Hellforge Crackme II (coded by LaZaRuS). Reading the rules you will find out that there are no rules; you can use any tool you want and try anything you wish to. Good! I decided to work with the exceedingly powerful SoftICE.
You will be asked for your name/handle ('Enter your lovely name here':)) and for a serial ('And here is the place to put the correct serial'). So why not? Enter your handle and a fake code (you should always use the same fake code when you're working on those programs because it will be easier to find later when you're fighting through the code jungle).
Now enter SoftICE with Ctrl-D and set a breakpoint on hmemcpy ('bpx hmemcpy'). Go back to your Crackme window by leaving SoftICE (Ctrl-D again) and press the 'Click here to check your serial!!!'-button now.
SoftIce will immediately pop up - breakpoint on hmemcpy. As we have two boxes (name and serial) we can press F5 ('Go') here once to save us some time. Now we can disable the breakpoint by typing bd0. To come to the interesting places we press F11 ('Go to') once and then F12 ('Return from the procedure call') until we reach the Hf_crackme_s1-code (watch the line between the Code window and the Command window). Some more F12's will bring us to this place:
:00426885 E8C6B3FEFF call 00411C50
:0042688A 8B45FC mov eax, dword ptr [ebp-04] ;<---we land here, our handle :0042688D E896CCFDFF call 00403528 ;is copied to eax
In 004268CF your name/handle is copied to the eax register. Then the first char (Hex value of the Ascii representation of the char) of your name is copied to eax (004268D2). Now it's copied to esi and the math begins; result one is stored in esi.
Same procedure for the second char of your handle, another (different) calculations and finally the result two (in eax) is added to our result one in esi.
...your fake code is copied to edx and eax contains the real code again...
:00426974 E8FBCAFDFF call 00403474
The 'comparison-call'! Within this call your fake serial is compared to the real serial. You can find out how this works by tracing into the call with F8.
:00426979 7518 jne 00426993
...the good guy/bad guy jump...you better do not jump here eh?!
:0042697B 6A00 push 00000000
* Possible StringData Ref from Code Obj ->"Congratulations"
|
:0042697D B9F0694200 mov ecx, 004269F0
* Possible StringData Ref from Code Obj ->"You did it"
Short conclusion: Your name/handle must be at least four chars long because the calculation routine is based on the first four chars. Finally the calculated code is multiplied with the length of your name.
Well a very nice Crackme indeed from LaZaRuS. I really hope Hellforge will publish more releases soon.
Last words: I just want to thank Jeff for being a real friend...!!!